import request from '@/utils/request'
import {useApp} from "@/pinia/modules/app";

// 分页查询
export const GetStudentListByPage = (pageNum, pageSize, queryDto) => {
    return request({
        url: '/admin/school/student/findByPage/' + pageNum + '/' + pageSize,
        method: 'get',
        params: queryDto,
    })
}

// 新增学生的方法
export const SaveStudent = data => {
    return request({
        url: '/admin/school/student/saveStudent',
        method: 'post',
        data: data,
    })
}

// 修改学生数据的方法
export const UpdateStudent = student => {
    return request({
        url: '/admin/school/student/updateStudent',
        method: 'put',
        data: student,
    })
}

// 根据id删除学生
export const DeleteStudentByStudentNumber = studentNumber => {
    return request({
        url: '/admin/school/student/deleteStudentByStudentNumber/' + studentNumber,
        method: 'delete',
    })
}
// 批量删除
export const DeleteStudents = (studentIds) => {
    const params = studentIds.join(',');
    return request({
        url: '/admin/school/student/deleteStudents',
        method: 'delete',
        params: {studentIds: params}
    });
}

//下载模板
export const DownloadTemplate = () => {
    return fetch({
        url: '/admin/school/student/downloadTemplate',
        method: 'get',
        headers: {
            token: useApp().authorization.token
        }
    })
}
